package com.lywz.biz.dao.food.impl;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.lywz.biz.common.dao.AbstractBaseDao;
import com.lywz.biz.common.entity.goodfood.FoodType;
import com.lywz.biz.dao.food.FoodTypeDao;

@Repository("foodTypeDao")
public class FoodTypeDaoImpl extends AbstractBaseDao implements FoodTypeDao {

    @SuppressWarnings("unchecked")
    @Override
    public String getDescriptionById(int foodTypeId) throws Exception {
        // TODO
        // XXX 是否还要用，不用则直接去掉
        /*
         * String sql = "from FoodType where foodTypeId = 6"; List l = (List)
         * session().createQuery(sql).list();
         * LogClerk.sysout.error("@@@@@@@@@@@@@@@@@"+l.size());
         */
        Query query = session().getNamedQuery("FoodType.getDescriptionById");
        query.setParameter("foodTypeId", foodTypeId);
        List<FoodType> list1 = query.list();
        System.out.println(list1.get(0).getFoodTopTypeDescription());

        if (query.list().isEmpty()) {
            return null;
        } else {
            return list1.get(0).getFoodTopTypeDescription();
        }
        // else return (String) query.list().get(0).;
    }

}
